package zzps.exeed.kernel.core;

import zzps.exeed.kernel.annotation.Panda;
import zzps.exeed.kernel.holder.MethodHolder;
import zzps.exeed.kernel.holder.PandaHolder;
import zzps.exeed.kernel.pandabuilder.PandaBuilder;

import java.lang.annotation.Annotation;
import java.util.Map;
import java.util.function.Consumer;

public class PandaEmbryo<T extends Annotation> {

    private String name;
    //panda类型
    private Class<?> clazz;
    private PandaBuilder<T> pandaBuilder;
    protected T embryoAnnotation;
    private Map<MethodHolder, Panda> childs;

    public PandaEmbryo(String name,Class<?> clazz, T embryoAnnotation,PandaBuilder<T> pandaBuilder) {
        this.name = name == null ? clazz.getCanonicalName():name;
        this.clazz = clazz;
        this.embryoAnnotation = embryoAnnotation;
        this.pandaBuilder = pandaBuilder;
    }

    public String name() {
        return name;
    }
    public Class<?> clazz() {
        return clazz;
    }

    public T embryoAnnotation() {
        return embryoAnnotation;
    }

    public Map<MethodHolder,Panda> childs() {
        return childs;
    }

    public void childs(Map<MethodHolder, Panda> childs) {
        this.childs = childs;
    }

    public void build(Consumer<PandaHolder> consumer, PandaContainer pandaContainer){
        pandaBuilder.build(this,consumer, pandaContainer);
    }
}
